﻿using System.Collections;
using System.Collections.Generic;

namespace WinFormsMVC
{
    public class ViewUserControlCollection
    {
        private IDictionary<string, string> collection = new Dictionary<string, string>();

        public void Add(string controller, string action, string qualifiedName)
        {
            collection.Add(GetKey(controller, action), qualifiedName);
        }

        public bool ContainsKey(string controller, string action)
        {
            return collection.ContainsKey(GetKey(controller, action));
        }

        private ICollection<string> Keys
        {
            get
            {
                return collection.Keys;
            }
        }

        public bool Remove(string controller, string action)
        {
            return collection.Remove(GetKey(controller, action));
        }

        public bool TryGetValue(string controller, string action, out string qualifiedName)
        {
            return collection.TryGetValue(GetKey(controller, action), out qualifiedName);
        }

        public ICollection<string> Values
        {
            get
            {
                return collection.Values;
            }
        }

        public string this[string controller, string action]
        {
            get
            {
                return collection[GetKey(controller, action)];
            }
            set
            {
                collection[GetKey(controller, action)] = value;
            }
        }

        private void Clear()
        {
            collection.Clear();
        }

        public int Count
        {
            get
            {
                return collection.Count;
            }
        }

        private IEnumerator GetEnumerator()
        {
            return collection.GetEnumerator();
        }

        private string GetKey(string controller, string action)
        {
            return controller + ":" + action;
        }
    }
}
